package math;

/**
 * Created by fengliejv on 2017/11/13.
 */
public class BinaryNumberwithAlternatingBits693 {
    public boolean hasAlternatingBits(int n) {
        while (n != 0) {
            int last1  = n & 1 ;

            int last2  = (n>>1) & 1;
            if((last1^last2)!=1){
                return false;
            }
            n = n>>1;
        }
        return true;
    }
}
